package migrations

import (
	"database/sql"

	"gitee.com/sweetsunnyflower/carpooling-server-go/app/models"
	"gitee.com/sweetsunnyflower/carpooling-server-go/pkg/migrate"

	"gorm.io/gorm"
)

// http://sql2struct.atotoa.com/
func init() {

	type Passenger struct {
		models.BaseModel

		UserId       uint64  `gorm:"column:user_id" db:"user_id" json:"user_id" form:"user_id"`
		Balance      float64 `gorm:"column:balance;comment:账号余额;" db:"balance" json:"balance" form:"balance"`    //账号余额
		Trip         int     `gorm:"column:trip;comment:拼车次数;" db:"trip" json:"trip" form:"trip"`                //出行次数
		Comments     int     `gorm:"column:comments;comment:评论数;" db:"comments" json:"comments" form:"comments"` //评论数
		FollowsCount int64   `gorm:"default:0;column:follows_count;comment:关注司机数;" db:"follows_count" json:"follows_count" form:"follows_count"`
		BlacksCount  int64   `gorm:"default:0;column:blacks_count;comment:拉黑司机数;" db:"blacks_count" json:"blacks_count" form:"blacks_count"`

		models.CommonTimestampsField
	}

	up := func(migrator gorm.Migrator, DB *sql.DB) {
		migrator.AutoMigrate(&Passenger{})
	}

	down := func(migrator gorm.Migrator, DB *sql.DB) {
		migrator.DropTable(&Passenger{})
	}

	migrate.Add("2023_07_18_114206_add_passengers_table", up, down)
}
